package org.filecollector.msgcontroller.answers;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.NonNull;
import org.filecollector.msgcontroller.answers.converters.SyncAnswerConverter;

public record SyncAnswerMessage(@NonNull Long operationID, @NonNull AnswerMessage answerMessage) {
    static Gson gsonParser = new GsonBuilder()
            .registerTypeAdapter(SyncAnswerMessage.class, new SyncAnswerConverter())
            .create();

    public static SyncAnswerMessage deserialize(String json) {
        return gsonParser.fromJson(json, SyncAnswerMessage.class);
    }

    public String serialize() {
        return gsonParser.toJson(this);
    }
}
